package java_class_work.week05;

import java.io.*;

/**
 * @Auther: admin
 * @Date: 2022/10/10 17:42
 * @Description: 复制图片
 */
public class CopyPicture {
    public static void main(String[] args) {
        // 原始文件
        String fileName = ".\\src\\java_class_work\\iotest\\课程表.png";
        // 目标位置
        String fileName1 = ".\\src\\java_class_work\\iotest\\课程表复印件.png";
        InputStream ips = null;
        OutputStream ops = null;
        try {
            ips = new FileInputStream(fileName);
            ops = new FileOutputStream(fileName1);
            int temp;
            // 读取到temp，同时写入目标文件
            while ((temp = ips.read()) != -1) ops.write(temp);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭流
            try {
                if (ips != null) ips.close();
                if (ops != null) ops.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
